import 'package:flutter/material.dart';

//Flutter 富文本
void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  FocusNode _focusNode = FocusNode();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: SizedBox.expand(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              //
              TextButton(
                onPressed: () {
                  print('点击了 text button');
                },
                child: Text('TextButton'),
              ),

              ElevatedButton(
                onPressed: () {
                  print('点击了  ElevatedButton');
                },
                onLongPress: () {
                  print('长按事件');
                },
                onHover: (hover) {
                  print('hover 事件 $hover');
                },
                onFocusChange: (focus) {
                  print('焦点 事件 $focus');
                },
                focusNode: _focusNode,
                autofocus: false,
                child: Text('ElevatedButton'),
              ),

              ElevatedButton.icon(
                icon: Icon(Icons.arrow_back),
                onPressed: () {
                  _focusNode.unfocus();
                },
                label: Text('图标ElevatedButton'),
              ),
              FilledButton(
                onPressed: () {
                  _focusNode.requestFocus();
                  print('点击了  FilledButton');
                },
                child: Text('FilledButton'),
              ),
              OutlinedButton(
                onPressed: () {
                  print('点击了  OutlinedButton');
                },
                child: Text('OutlinedButton'),
              ),
            ],
          ),
        ),
      ),
      // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
